package com.kaifamiao.www.demo.Do20;

public class De02 {
    public static void main(String[] args) {
  //选择排序
        double[] scores = new double[5];
        //math.random生成0-1之间的伪随机数
        for(int i = 0;i < scores.length;i++){
            double score = (int)(Math.random()*10000)/100.0;
            scores[i] = score;
        }
        System.out.println("排序前");//输出字符“排序前”
        //遍历输出
        for(int i = 0;i < scores.length;i++){
            System.out.print(scores[i]+"\t");
        }
        //排序  选择排序  升序
        //count 位置，坑
        for(int count = 0;count < scores.length-1;count++){
            int index = count;
            for(int i =index + 1;i < scores.length;i++){
                if(scores[i] < scores[index]){
                    index = i;
                }
            }
            //位置交换  temp
            double temp = scores[count];
            scores[count] = scores[index];
            scores[index] = temp;
        }
        System.out.println("\n排序后；");
        //遍历排序
        for(int i = 0;i < scores.length;i++){
            System.out.println(scores[i]+"\t");
        }
    }
}
